package util;

import java.util.List;
/**
 * 
 * 说明:自定义TabelModel工具类
 * 
 * @author LS
 * 
 * */
import java.util.Vector;

import javax.swing.table.AbstractTableModel;

public class TableData extends AbstractTableModel {
	private static final long serialVersionUID = -7046183097387903033L;
	
	List<String[]> rows;
	Vector<String> colums = new Vector<String>();

	public TableData(String[] columns, List<String[]> rows) {
		for (String colum : columns) {
			this.colums.add(colum);
		}
		this.rows = rows;
	}

	@Override
	public String getColumnName(int column) {
		return colums.get(column);
	}

	@Override
	public int getColumnCount() {
		return colums.size();
	}

	@Override
	public int getRowCount() {
		return rows.size();
	}

	@Override
	public Object getValueAt(int rowIndex, int columnIndex) {
		return rows.get(rowIndex)[columnIndex];
	}

    public void refresh(List<String[]> rows) {
		this.rows = rows;
		fireTableDataChanged();
	}
    
}
